package trece;

import globals.SystemGeneralState;

import java.sql.Connection;
import java.sql.SQLException;

import model.DatabaseCommons;
import model.PersonDAO;
import model.TelephoneDAO;
import model.TelephoneTypesDAO;
import controller.GlobalOperations;

public class TestDB {
	static PersonDAO pdb = new PersonDAO();
	TelephoneTypesDAO db = new TelephoneTypesDAO();
	static DatabaseCommons dbc = new DatabaseCommons();
	static Connection c = null;
	static SystemGeneralState sgs;
	static int lastPersonId, lastTelephoneId;
	static GlobalOperations gOps = new GlobalOperations();
	static TelephoneDAO telephoneDAO = new TelephoneDAO(); 

	public static void main(String[] args) throws SQLException {
		System.out.println("Running db test...");

		// DatabaseCommons dbc = new DatabaseCommons();

		// dbc.h2Connect();

		// testing by adding a couple of persons
		/*
		 * db.addPerson(new Person("alejandro", "alcaide",
		 * CollateralClient.noCollateral, false)); db.addPerson(new
		 * Person("lety", "ramos", CollateralClient.alejandroAlcaide, true));
		 */
		// db.saveToDB();

		// db.loadFromDB();

		// dbc.disconnect();

		// pdb.addPersonNoCommit();
		// dbc.startH2Server();

		pdb.addEmptyPerson();

		lastPersonId = gOps.getIntFromGlobal("lastPersonInserted");

		// idTelephoneType, idPerson, telephone
		telephoneDAO.addTelephone(1, lastPersonId, "123456");
		telephoneDAO.addTelephone(2, lastPersonId, "abcde");
		telephoneDAO.addTelephone(3, lastPersonId, "189733738*1728217");

		dbc.disconnect();
		// dbc.stopH2Server();

	}
}
